package com.lyh.hkcloud.module.common;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import com.lyh.hkcloud.R;
import com.lyh.hkcloud.base.BaseEntityViewAdapter;
import com.lyh.hkcloud.base.BaseViewHolder;

import java.util.List;
import java.util.Map;

public class SinglListViewAdapter extends BaseEntityViewAdapter<SinglListViewAdapter.ViewHolder, Map<String, String>> {


    public SinglListViewAdapter(Context context, List<Map<String, String>> list) {
        super(context, list);
    }

    @Override
    protected int getItemResuId() {
        return R.layout.activity_singl_list_listview_item;
    }

    @Override
    protected void initItem(int position, ViewHolder holder, View v, Map<String, String> obj) {
        holder.tvNo = v.findViewById(R.id.tv_no);
        holder.tvItem = v.findViewById(R.id.tv_item);
        holder.cbItem = v.findViewById(R.id.cb_item);
        v.setTag(R.id.tv_item, obj);
    }

    @Override
    protected void setItem(int position, ViewHolder holder, Map<String, String> obj) {
        holder.tvNo.setText(obj.get("no"));
        String item = obj.get("item");
        holder.tvItem.setText(item);
        holder.cbItem.setChecked("1".equals(obj.get("checked")));
    }


    public static class ViewHolder extends BaseViewHolder {
        public TextView tvNo;
        public TextView tvItem;
        public CheckBox cbItem;
    }
}

